//
// Created by Administrator on 2023/11/23.
//
#include <iostream>

using namespace std;

const int N = 1e5 + 10, M = 1e6 + 10;

int n, m;
char p[N], s[M];
int Next[N];

int main() {
    //p d右移一位 为了方便求next和匹配 下标从1开始
    cin >> n >> (p + 1) >> m >> (s + 1);
//求next数组
    //next[1]默认等于0 i从2开始
    for (int i = 2, j = 0; i <= n; i++) {
        while (j && p[i] != p[j + 1]) j = Next[j];
        if (p[i] == p[j + 1]) j++;
        Next[i] = j;
    }
//匹配
    for (int i = 1, j = 0; i <= m; i++) {
        while (j && s[i] != p[j + 1]) j = Next[j];
        if (s[i] == p[j + 1]) j++;
        if (j == n) {
            printf("%d ", i - n); /* 本题下标从0开始，与上文不同 */
            j = Next[j];
        }
    }
    return 0;
}
